﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FoodLight.Data;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

namespace FoodLight.VariableTemplate
{
    public class VariableTiles : DataTemplateSelector
    {

        public DataTemplate RecipesBigTemplate { get; set; }
        public DataTemplate RecipesSmallTemplate { get; set; }
        public DataTemplate CuisinesTemplate { get; set; }
        public DataTemplate DishSmallTemplate { get; set; }
        public DataTemplate PopularBigTemplate { get; set; }
        public DataTemplate PopularBigsceTemplate { get; set; }
        public DataTemplate PopularSmallTemplate { get; set; }
        public DataTemplate PopularSmallsecTemplate { get; set; }
        public DataTemplate CateryBigTemplate { get; set; }
       

        protected override DataTemplate SelectTemplateCore(object item, DependencyObject container)
        {
            FrameworkElement element = container as FrameworkElement;

            if (element != null && item != null)
            {

                if (item.GetType() == typeof(SampleDataItem))
                {

                    if ((item as SampleDataItem).UniqueId.StartsWith("Recipes"))
                        return RecipesBigTemplate;
                    if ((item as SampleDataItem).UniqueId.StartsWith("RpsSmall"))
                        return RecipesSmallTemplate;
                    if ((item as SampleDataItem).UniqueId.StartsWith("CuisinesSmall"))
                        return CuisinesTemplate;
                    if ((item as SampleDataItem).UniqueId.StartsWith("DishSmall"))
                        return DishSmallTemplate;
                    if ((item as SampleDataItem).UniqueId.StartsWith("PopularBigSmall"))
                        return PopularBigTemplate;
                    if ((item as SampleDataItem).UniqueId.StartsWith("PopularBigsceSmall"))
                        return PopularBigsceTemplate;
                    if ((item as SampleDataItem).UniqueId.StartsWith("PopularSmall"))
                        return PopularSmallTemplate;
                    if ((item as SampleDataItem).UniqueId.StartsWith("PsSSmall"))
                        return PopularSmallsecTemplate;
                }



                else if (item.GetType() == typeof(CategoryDataItem))
                {
                    if ((item as CategoryDataItem).UniqueId.StartsWith("Recipes"))
                        return RecipesBigTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("RpsSmall"))
                        return RecipesSmallTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("CuisinesSmall"))
                        return CuisinesTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("DishSmall"))
                        return DishSmallTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("PopularBigSmall"))
                        return PopularBigTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("PopularBigsceSmall"))
                        return PopularBigsceTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("PopularSmall"))
                        return PopularSmallTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("PsSSmall"))
                        return PopularSmallsecTemplate;
                    if ((item as CategoryDataItem).UniqueId.StartsWith("CatNew"))
                        return CateryBigTemplate;

                }
            }
           

            return base.SelectTemplateCore(item, container);
        }

    }
}
